package com.demo.coupon;

import com.demo.AppletConstant;
import com.demo.util.Utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


/**
 *  红包 (机构账户)余额查询
 *
 */
public class RedPacketSelect {
	public static SimpleDateFormat SDF_YMD = new SimpleDateFormat("yyyyMMdd");
	public static SimpleDateFormat SDF_HMS = new SimpleDateFormat("yyyyMMddHHmmss");
	public static void main(String[] args) {
		try{
			String resultStr = getRedPacketSelect();
			System.out.println("-------获取RedPacketSelect信息:"+resultStr+"---------");
		}catch (Exception e){
			e.printStackTrace();
		}
	}

	public static String getRedPacketSelect() throws Exception{

		//调用地址
		String url = "https://open.95516.com/open/access/1.0/red.packet.select";
		//拼装参数Map
		Map<String, String> params = new HashMap<String, String>(0);
		params.put("appId", AppletConstant.APP_ID);
		params.put("insAcctId", "");
		//接入方交易流水号
		params.put("transNumber", "696722484692728");
		//请求日期 YYYYMMDD
		//例：20190712
		params.put("transDt", SDF_YMD.format(new Date()));
		//请求时间 YYYYMMDDHHMMSS
		//例：20190712144820
		params.put("transTm", SDF_HMS.format(new Date()));
		//OAUTH2中获取的openId
		params.put("backendToken", AppletConstant.backendToken);
		params.put("insAcctType", "");

		//发送请求
		String resultStr = Utils.sendPostGson(url, params);
		return resultStr;
	}
	
}
